use a signed type for waypt_counts and route counts. (#1307)
authortsteven4 <13596209+tsteven4@users.noreply.github.com>
Tue, 30 Jul 2024 23:31:08 +0000 (17:31 -0600)
committerGitHub <noreply@github.com>
Tue, 30 Jul 2024 23:31:08 +0000 (17:31 -0600)
* use a signed type for waypt_counts and route counts.

Although larger in Qt6, the underlying type is signed.

* fix -Wformat-signedness warnings introduced by this PR.

* fix new -Wsign-conversion warnings.

defs.h
kml.cc
kml.h
route.cc
tpg.h
validate.cc
validate.h
waypt.cc

diff --git a/defs.h b/defs.h
index 93f2b5d0bb21756ad52fa52f7bad47de8530a7cf..ae382c9241ec5f9fdd0bf6c0f2977155e270feb2 100644 (file)
--- a/defs.h
+++ b/defs.h
@@ -490,7 +490,7 @@ void waypt_init();
 void waypt_add(Waypoint* wpt);
 void waypt_del(Waypoint* wpt);
 void del_marked_wpts();
-unsigned int waypt_count();
+int waypt_count();
 void waypt_status_disp(int total_ct, int myct);
 //void waypt_disp_all(waypt_cb); /* template */
 //void waypt_disp_session(const session_t* se, waypt_cb cb); /* template */
@@ -674,10 +674,10 @@ private:
 };
 
 void route_init();
-unsigned int route_waypt_count();
-unsigned int route_count();
-unsigned int track_waypt_count();
-unsigned int track_count();
+int route_waypt_count();
+int route_count();
+int track_waypt_count();
+int track_count();
 route_head* route_head_alloc();
 void route_add_head(route_head* rte);
 void route_del_head(route_head* rte);
diff --git a/kml.cc b/kml.cc
index db5bfbd7578a6ab8dd271e0f6cf6004e9b41283d..cacf0385c9ce9f6e2e29166169dc50bb4c4e415f 100644 (file)
--- a/kml.cc
+++ b/kml.cc
@@ -90,7 +90,7 @@ const QVector<KmlFormat::mt_field_t> KmlFormat::mt_fields_def = {
   { wp_field::sat, "satellites", "Satellites", "int" },
 };
 
-void KmlFormat::kml_init_color_sequencer(unsigned int steps_per_rev)
+void KmlFormat::kml_init_color_sequencer(int steps_per_rev)
 {
   if (rotate_colors) {
     float color_step = strtod(opt_rotate_colors, nullptr);
diff --git a/kml.h b/kml.h
index eef489c57b4d1066ca4970f3af0da0522c189062..4ed4d400818126b60eb5a8a46ac46c073b2cde24 100644 (file)
--- a/kml.h
+++ b/kml.h
@@ -132,7 +132,7 @@ private:
 
   /* Member Functions */
 
-  void kml_init_color_sequencer(unsigned int steps_per_rev);
+  void kml_init_color_sequencer(int steps_per_rev);
   static constexpr int kml_bgr_to_color(int blue, int green, int red)
   {
     return (blue)<<16 | (green)<<8 | (red);
index a065bd5fb5fc8a0d8408c60665fb8a6c501b7e9c..c4c25f56e93b98cbf1f2de3665a9aafbaae68fcf 100644 (file)
--- a/route.cc
+++ b/route.cc
@@ -46,27 +46,27 @@ route_init()
   global_track_list = new RouteList;
 }
 
-unsigned int
+int
 route_waypt_count()
 {
   /* total waypoint count -- all routes */
   return global_route_list->waypt_count();
 }
 
-unsigned int
+int
 route_count()
 {
   return global_route_list->count();   /* total # of routes */
 }
 
-unsigned int
+int
 track_waypt_count()
 {
   /* total waypoint count -- all tracks */
   return global_track_list->waypt_count();
 }
 
-unsigned int
+int
 track_count()
 {
   return global_track_list->count();   /* total # of tracks */
diff --git a/tpg.h b/tpg.h
index 6f4b098d39446567f60c880b2f9adaad0fa3dab1..0fa129b3b61ae0aa9f68b93e04da699c30c01184 100644 (file)
--- a/tpg.h
+++ b/tpg.h
@@ -75,7 +75,7 @@ private:
   char* tpg_datum_opt{};
   int tpg_datum_idx{};
 
-  unsigned int waypt_out_count{};
+  int waypt_out_count{};
 
   QVector<arglist_t> tpg_args = {
     {"datum", &tpg_datum_opt, "Datum (default=NAD27)", "N. America 1927 mean", ARGTYPE_STRING, ARG_NOMINMAX, nullptr},
index 23cf30b815009471caacd6e69488d9b97984f1c7..f3d20d6648069a4a0b154746ad0f15c5e331350f 100644 (file)
@@ -64,10 +64,10 @@ void ValidateFilter::process()
   }
   waypt_disp_all(validate_point_f);
   if (debug) {
-    fprintf(stderr, "point ct: %u, waypt_count: %u\n", point_ct, waypt_count());
+    fprintf(stderr, "point ct: %d, waypt_count: %d\n", point_ct, waypt_count());
   }
   if (!debug && (point_ct != waypt_count())) {
-    fatal(MYNAME ":Waypoint count mismatch, expected %u, actual %u\n", waypt_count(), point_ct);
+    fatal(MYNAME ":Waypoint count mismatch, expected %d, actual %d\n", waypt_count(), point_ct);
   }
 
   head_ct = 0;
@@ -78,14 +78,14 @@ void ValidateFilter::process()
   }
   route_disp_all(validate_head_f, validate_head_trl_f, validate_point_f);
   if (debug) {
-    fprintf(stderr, "route head ct: %u, route_count: %u\n", head_ct, route_count());
-    fprintf(stderr, "total route point ct: %u, route_waypt_count: %u\n", point_ct, route_waypt_count());
+    fprintf(stderr, "route head ct: %d, route_count: %d\n", head_ct, route_count());
+    fprintf(stderr, "total route point ct: %d, route_waypt_count: %d\n", point_ct, route_waypt_count());
   }
   if (!debug && (head_ct != route_count())) {
-    fatal(MYNAME ":Route count mismatch, expected %u, actual %u\n", route_count(), head_ct);
+    fatal(MYNAME ":Route count mismatch, expected %d, actual %d\n", route_count(), head_ct);
   }
   if (!debug && (point_ct != route_waypt_count())) {
-    fatal(MYNAME ":Total route waypoint count mismatch, expected %u, actual %u\n", route_waypt_count(), point_ct);
+    fatal(MYNAME ":Total route waypoint count mismatch, expected %d, actual %d\n", route_waypt_count(), point_ct);
   }
 
   head_ct = 0;
@@ -96,14 +96,14 @@ void ValidateFilter::process()
   }
   track_disp_all(validate_head_f, validate_head_trl_f, validate_point_f);
   if (debug) {
-    fprintf(stderr, "track head ct: %u, track_count: %u\n", head_ct, track_count());
-    fprintf(stderr, "total track point ct: %u, track_waypt_count: %u\n", point_ct, track_waypt_count());
+    fprintf(stderr, "track head ct: %d, track_count: %d\n", head_ct, track_count());
+    fprintf(stderr, "total track point ct: %d, track_waypt_count: %d\n", point_ct, track_waypt_count());
   }
   if (!debug && (head_ct != track_count())) {
-    fatal(MYNAME ":Track count mismatch, expected %u, actual %u\n", track_count(), head_ct);
+    fatal(MYNAME ":Track count mismatch, expected %d, actual %d\n", track_count(), head_ct);
   }
   if (!debug && (point_ct != track_waypt_count())) {
-    fatal(MYNAME ":Total track waypoint count mismatch, expected %u, actual %u\n", track_waypt_count(), point_ct);
+    fatal(MYNAME ":Total track waypoint count mismatch, expected %d, actual %d\n", track_waypt_count(), point_ct);
   }
 
   if (checkempty) {
index eff779d5ce3533c338d01429b59c7d25cbed7727..7a91388dcc9e090ea9684534992f0250b018a1ed 100644 (file)
@@ -44,9 +44,9 @@ private:
   bool debug{};
   char* opt_checkempty{};
   bool checkempty{};
-  unsigned int point_ct{};
-  unsigned int head_ct{};
-  unsigned int segment_ct_start{};
+  int point_ct{};
+  int head_ct{};
+  int segment_ct_start{};
   const char* segment_type{};
   QVector<arglist_t> args = {
     {
index f7f0783b8d1d9cb2f081eab351a166cf732893e6..e7c8c1898b59074081762338f97b9b74fa98ebc3 100644 (file)
--- a/waypt.cc
+++ b/waypt.cc
@@ -73,7 +73,7 @@ del_marked_wpts()
   global_waypoint_list->del_marked_wpts();
 }
 
-unsigned int
+int
 waypt_count()
 {
   return global_waypoint_list->count();